import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:kuaitong/units/screen_units.dart';

class SwiperPage extends StatefulWidget {
  @override
  SwiperPageState createState() {
    return SwiperPageState();
  }
}

class SwiperPageState extends State<SwiperPage> {
  Widget _swiperBuilder(BuildContext context, int index) {
    final screen = Screen(context);
    return (Image.asset('assets/swiper.png',width:screen.width,fit: BoxFit.fill,));
  }

  @override
  Widget build(BuildContext context) {
    final screen = Screen(context);
    return Container(
        width: screen.width,
        height: screen.salc(300),
        child: Swiper(
          itemBuilder: _swiperBuilder,
          itemCount: 4,
          pagination: new SwiperPagination(
              builder: DotSwiperPaginationBuilder(
            color: Colors.black54,
            activeColor: Colors.white,
          )),
          control: null,
          scrollDirection: Axis.horizontal,
          autoplay: true,
          onTap: (index) => print('点击了第$index个'),
        ));
  }
}
